// 从本地获取信息并渲染
const userId = localStorage.getItem('user-id')
const token = localStorage.getItem('user-token')

//如果能获取到用户id，则渲染首页面中购物车商品的数量
if(userId && token) {
  axios({
    url:'/cart/list',
    headers:{
      'Access-Token':token,
      platform:'H5'
    }
  }).then(result=>{
    console.log(result)
    // console.log(result.data.data.cartTotal)
    if(result.data.data.cartTotal === 0) {
      document.querySelector('.car_number').style.display = 'none'
    } else {
      document.querySelector('.car_number').innerHTML= result.data.data.cartTotal
      document.querySelector('.car_number').style.display = 'block'
    }
  })
} else {
  document.querySelector('.car_number').style.display = 'none'
}
